package ihm;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.DefaultComboBoxModel;
import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JTextField;
import javax.swing.LayoutStyle.ComponentPlacement;
import java.awt.Dialog.ModalityType;

public class FenetreAjouterTache {

	private JDialog frmAjouterUneTche;
	private JTextField txtLibelleTache;
	private JTextField txtChargeTache;

	/**
	 * Create the application.
	 */
	public FenetreAjouterTache() {
		initialize();
	}

	public JDialog getFrmAjouterUneTche() {
		return frmAjouterUneTche;
	}
	
	/**
	 * Initialize the contents of the frame.
	 */
	private void initialize() {
		frmAjouterUneTche = new JDialog();
		frmAjouterUneTche.setModalityType(ModalityType.APPLICATION_MODAL);
		frmAjouterUneTche.setModal(true);
		frmAjouterUneTche.setTitle("Ajouter une tâche");
		frmAjouterUneTche.setBounds(100, 100, 350, 245);
		frmAjouterUneTche.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
		
		JLabel lblLibell = new JLabel("Libellé :");
		
		JLabel lblChargePrvisionnelle = new JLabel("Charge prévisionnelle :");
		
		JLabel lblCollaborateur = new JLabel("Collaborateur :");
		
		JLabel lblContrat = new JLabel("Contrat :");
		
		txtLibelleTache = new JTextField();
		txtLibelleTache.setColumns(10);
		
		txtChargeTache = new JTextField();
		txtChargeTache.setColumns(10);
		
		JList list = new JList();
		
		JComboBox cboCollaborateur = new JComboBox();
		cboCollaborateur.setModel(new DefaultComboBoxModel(new String[] {"PLEIN Y'en a assez", "SHOGUN Tonight", "ONESTTOUS Motivé ", "SALUT C'estCool", "LAVACHE Kirikirikiri", "COUCOU Hibou"}));
		
		JComboBox cboContrat = new JComboBox();
		cboContrat.setModel(new DefaultComboBoxModel(new String[] {"BLABLABLA "}));
		
		JButton btnValider = new JButton("Valider");
		
		JButton btnAnnuler = new JButton("Annuler");
		btnAnnuler.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				frmAjouterUneTche.dispose();
			}
		});
		GroupLayout groupLayout = new GroupLayout(frmAjouterUneTche.getContentPane());
		groupLayout.setHorizontalGroup(
			groupLayout.createParallelGroup(Alignment.LEADING)
				.addGroup(groupLayout.createSequentialGroup()
					.addGap(112)
					.addComponent(list, GroupLayout.PREFERRED_SIZE, 1, GroupLayout.PREFERRED_SIZE)
					.addGap(162))
				.addGroup(groupLayout.createSequentialGroup()
					.addGap(49)
					.addGroup(groupLayout.createParallelGroup(Alignment.LEADING)
						.addGroup(groupLayout.createSequentialGroup()
							.addGap(48)
							.addGroup(groupLayout.createSequentialGroup()
								.addComponent(btnValider, GroupLayout.DEFAULT_SIZE, 81, Short.MAX_VALUE)
								.addPreferredGap(ComponentPlacement.UNRELATED)
								.addComponent(btnAnnuler, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
							.addGap(45))
						.addGroup(groupLayout.createSequentialGroup()
							.addGroup(groupLayout.createParallelGroup(Alignment.LEADING)
								.addComponent(lblLibell)
								.addComponent(lblChargePrvisionnelle)
								.addComponent(lblCollaborateur)
								.addComponent(lblContrat))
							.addGap(23)
							.addGroup(groupLayout.createParallelGroup(Alignment.LEADING)
								.addComponent(cboContrat, 0, 120, Short.MAX_VALUE)
								.addComponent(cboCollaborateur, 0, 120, Short.MAX_VALUE)
								.addComponent(txtLibelleTache, GroupLayout.DEFAULT_SIZE, 120, Short.MAX_VALUE)
								.addComponent(txtChargeTache, GroupLayout.DEFAULT_SIZE, 120, Short.MAX_VALUE))))
					.addGap(48))
		);
		groupLayout.setVerticalGroup(
			groupLayout.createParallelGroup(Alignment.LEADING)
				.addGroup(groupLayout.createSequentialGroup()
					.addGap(18)
					.addGroup(groupLayout.createParallelGroup(Alignment.BASELINE)
						.addComponent(lblLibell)
						.addComponent(txtLibelleTache, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
					.addGap(18)
					.addGroup(groupLayout.createParallelGroup(Alignment.BASELINE)
						.addComponent(lblChargePrvisionnelle)
						.addComponent(txtChargeTache, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
					.addGap(18)
					.addGroup(groupLayout.createParallelGroup(Alignment.BASELINE)
						.addComponent(lblCollaborateur)
						.addComponent(cboCollaborateur, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
					.addGap(18)
					.addGroup(groupLayout.createParallelGroup(Alignment.BASELINE)
						.addComponent(lblContrat)
						.addComponent(cboContrat, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
					.addGap(14)
					.addGroup(groupLayout.createParallelGroup(Alignment.BASELINE)
						.addComponent(btnValider)
						.addComponent(btnAnnuler))
					.addGap(18)
					.addComponent(list, GroupLayout.PREFERRED_SIZE, 1, GroupLayout.PREFERRED_SIZE)
					.addContainerGap(54, Short.MAX_VALUE))
		);
		frmAjouterUneTche.getContentPane().setLayout(groupLayout);
	}
	
	public void remplirCboCollaborateur() {
		
	}
	
	public void remplirCboContrat() {
		
	}
}
